package cn.xiaohuodui.rest;

import cn.xiaohuodui.exceptions.BussException;
import cn.xiaohuodui.form.user.*;
import cn.xiaohuodui.service.UserService;
import cn.xiaohuodui.vo.user.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author :keepcleargas
 * Date   :2017-06-21 21:46.
 */
@RestController
@RequestMapping("/v1/users")
public class UserApi {
    @Autowired
    UserService userService;

//    /**
//     * 登录
//     *
//     * @param form
//     * @return
//     */
//    @RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public UserVo login(@ModelAttribute LoginForm form) throws BussException {
//        return userService.login(form);
//    }
//
//    /**
//     * 用户名注册 密码 推荐人
//     *
//     * @param form
//     * @return
//     */
//    @RequestMapping(value = "/reg", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public UserVo reg(@ModelAttribute UserPhoneForm form) throws BussException {
//        userService.reg(form);
//        LoginForm loginForm = new LoginForm();
//        loginForm.setAccount(form.getPhone());
//        loginForm.setPassword(form.getPassword());
//        loginForm.setDevice(form.getDevice());
//        loginForm.setPlatform(form.getPlatform());
//        return userService.login(loginForm);
//    }
//
//    /**
//     * 新手机号 发送验证码
//     *
//     * @param form
//     * @return
//     */
//    @RequestMapping(value = "/sms", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public
//    @ResponseBody
//    void sendSms(@ModelAttribute PhoneForm form) throws BussException {
//        if (form.getSmsType() == 0) {
//            userService.sendRegSms(form);
//        } else if (form.getSmsType() == 1) {
//            userService.sendPwdSms(form);
//        }
//        return;
//    }
//
//    /**
//     * 找回密码
//     *
//     * @param findPwdForm
//     * @return
//     */
//    @RequestMapping(value = "/findPwd", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public void findPwd(@ModelAttribute FindPwdForm findPwdForm) throws BussException {
//        userService.findPwd(findPwdForm);
//        return;
//    }
//
//    /**
//     * 重置密码
//     *
//     * @param resetForm
//     * @return
//     */
//    @RequestMapping(value = "/{logged}/password", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public void resetPwd(@PathVariable("logged") int logged, @ModelAttribute ResetPwdForm resetForm) throws BussException {
//        resetForm.setUid(logged);
//        userService.updatePwd(resetForm);
//        return;
//    }
//
//    /**
//     * 完善信息
//     *
//     * @param profileForm
//     * @return
//     */
//    @RequestMapping(value = "/{logged}/profile", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public void profile(@PathVariable("logged") int logged, @ModelAttribute ProfileForm profileForm) throws BussException {
//        profileForm.setUid(logged);
//        userService.updateProfile(profileForm);
//        return;
//    }
//
//    /**
//     * 登出
//     *
//     * @param logoutForm {@link LogoutForm}
//     * @return
//     */
//    @RequestMapping(value = "/{logged}/logout", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public void logout(@ModelAttribute LogoutForm logoutForm) throws BussException {
//        userService.logout(logoutForm);
//    }
}
